package calculator;

import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        String str;
        double num_1,num_2;
        add op_add = new add();
        cut op_cut = new cut();
        multiply op_multiply = new multiply();
        eliminate op_eliminate = new eliminate();
        Scanner scan = new Scanner(System.in);
        System.out.print("please input you want op(+-*/ and `a` can end ): ");
        do {
            str = scan.next();
            switch(str)
            {
                case "+":
                    System.out.print("this is + ,please input two numbers: ");
                    num_1 = scan.nextDouble();
                    num_2 = scan.nextDouble();
                    System.out.println("the result is " + op_add.Add(num_1,num_2));
                    System.out.println("go on!");
                    break;
                case "-"://1.1-2会造成精度误差的问题，还没有解决
                    System.out.print("this is -,please input two numbers: ");
                    num_1 = scan.nextDouble();
                    num_2 = scan.nextDouble();
                    System.out.println("the result is " + op_cut.Cut(num_1,num_2));
                    System.out.println("go on!");
                    break;
                case "*":
                    System.out.print("this is *,please input two numbers: ");
                    num_1 = scan.nextDouble();
                    num_2 = scan.nextDouble();
                    System.out.println("the result is " + op_multiply.Multiply(num_1,num_2));
                    System.out.println("go on!");
                    break;
                case "/":
                    System.out.print("this is /,please input two numbers: ");
                    num_1 = scan.nextDouble();
                    num_2 = scan.nextDouble();
                    System.out.println("the result is " + op_eliminate.Eliminate(num_1,num_2));
                    System.out.println("go on!");
                    break;
                default:
                    if(!str.equals("a")){System.out.print("wrong! please input again");}
                    else{
                        System.out.print("the exe end");
                    }
            }
        }while(!str.equals("a"));


    }
}
